package com.example.treasure_back.controller;

import com.example.treasure_back.entity.MsgEntity;
import com.example.treasure_back.enumerate.ExchangeType;
import com.example.treasure_back.model.vo.ExchangeViewModel;
import com.example.treasure_back.service.ExchangeRecordService;
import com.example.treasure_back.shiroEntity.auth.AuthUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/treasure/exchange")
public class ExchangeRecordController {

    @Autowired
    private ExchangeRecordService exchangeRecordService;

    @RequestMapping("/getRecords/{status}")
    public MsgEntity getRecords(@AuthUser String email,@PathVariable ExchangeType status){
        List<ExchangeViewModel> exchangeRecords = exchangeRecordService.getExchangeRecordsByType(email, status);
        return new MsgEntity("SUCCESS", "200", exchangeRecords);
    }
}
